
import data from '../lib/data.js'

const newData = {}
class Blossom {
    constuctor() {
    }

    /**
     * {
     *   sum: 和，
     *   sumNew:
     *   sumIsRight: 和对错  默认:true 对  false:错
     *   bigSmall: 大小   默认:true 大  false:小
     *   bigSmallNew
     *   bigSmallIsRight:大小对错
     *   singleDouble:  默认:true 单  false:双
     *   singleDoubleNew:
     *   singleDoubleIsRight:单双对错
     *   value:[] 值
     *   newValue:[]
     *   isOpen:boolean 是否已开  默认:true已开 false:未开
     *   
     * }
     */

    method() {
        const keyArr = Object.keys(data)

        keyArr.map((item, index) => {
            const key1 = keyArr[index]
            const key2 = keyArr[index + 1]
            const key3 = keyArr[index + 2]



            if (data[key2] && data[key3]) {
                const sum = this.sum(data[key3])
                newData[key3] = {}

                newData[key3].value = data[key3]
                newData[key3].sum = sum
                newData[key3].isOpen = sum ? true : false
                newData[key3].bigSmall = sum >= 9 ? true : false
                newData[key3].singleDouble = sum % 2 == 1 ? true : false


                const value1 = (data[key1][0] + data[key2][0]) % 6
                const value2 = (data[key1][1] + data[key2][1]) % 6
                const value3 = (data[key1][2] + data[key2][2]) % 6

                const newValue = value1 + value2 + value3
                const bigSmallNew = newValue >= 9 ? true : false
                const singleDoubleNew = newValue % 2 == 1 ? true : false

                newData[key3].newValue = []
                newData[key3].newValue.push(value1)
                newData[key3].newValue.push(value2)
                newData[key3].newValue.push(value3)

                newData[key3].sumNew = newValue
                newData[key3].sumIsRight = newValue == sum ? true : false
                newData[key3].bigSmallNew = bigSmallNew
                newData[key3].bigSmallIsRight = bigSmallNew == newData[key3].bigSmall ? true : false
                newData[key3].singleDoubleNew = singleDoubleNew
                newData[key3].singleDoubleIsRight = singleDoubleNew == newData[key3].singleDouble ? true : false

            }
        })
    }

    sum(arr) {
        return arr[0] + arr[1] + arr[2]
    }


}


export default new Blossom()
